package com.desay.pangoo.itmt.entity;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Data;

/**
 * @author uidq1163 on [2022年09月22日上午10:16:03] <br>
 *         work group Tech classification 工作组技术分类:技术相信信息
 * @Modified By： [修改人] on [修改日期] for [修改说明]
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "tech_project_info_history")
@Data
public class TechProjectInfoHistoryEntity extends BaseEntity implements Serializable {

	private static final long serialVersionUID = -521479454636636485L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", columnDefinition = "bigint COMMENT '主键'")
	private Long id;

	@ManyToOne(fetch = FetchType.EAGER, optional = true)
	@JoinColumn(name = "tech_class_id")
	private TechClassificationEntity techClass;

	@Column(name = "tech_ptn", nullable = false, columnDefinition = "varchar(255) COMMENT '技术编号'")
	private String techPtn;

	@Column(name = "research_forms", nullable = false, columnDefinition = "varchar(255) COMMENT '研究形式'")
	private String researchForms;

	@Column(name = "tech_name", nullable = false, columnDefinition = "text COMMENT '技术名称'")
	private String techName;

	@Column(name = "subsidiary", nullable = true, columnDefinition = "varchar(255) COMMENT '子技术'")
	private String subsidiary;

	@Column(name = "description", nullable = true, columnDefinition = "mediumtext COMMENT '说明'")
	private String description;

	@Column(name = "tech_level", nullable = false, columnDefinition = "int COMMENT '技术等级:核心:1，关键:2，通用:3，一般:4'")
	private Integer techLevel;

	@Column(name = "priority", nullable = false, columnDefinition = "varchar(50) COMMENT '优先级'")
	private String priority;

	/** 项目对应的时间线状态 */
	@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinColumn(name = "tech_project_id")
	@OrderBy("year,quarter")
	@JsonIgnoreProperties({ "techProject" })
	private Set<TechYearQuarterHistoryEntity> techYearQuarters;

	@Column(name = "quantitative_indicators", nullable = true, columnDefinition = "mediumtext COMMENT '量化指标'")
	private String quantitativeIndicators;

	@Column(name = "tmt_approval", nullable = true, columnDefinition = "varchar(50) COMMENT 'TMT 评审'")
	private String tMTApproval;

	@Column(name = "maturity", nullable = true, columnDefinition = "varchar(50) COMMENT '技术状态'")
	private String maturity;

	@Column(name = "requirement_source", nullable = true, columnDefinition = "varchar(50) COMMENT '需求来源'")
	private String requirementSource;

	@Column(name = "developed_by", nullable = true, columnDefinition = "varchar(50) COMMENT '开发负责人'")
	private String developedBy;

	/** 设备需求 */
	@Column(name = "tools_equipment", nullable = true, columnDefinition = "varchar(255) COMMENT '设备需求'")
	private String toolsEquipment;
	/** 资源需求(人月） */
	@Column(name = "resource_needed", nullable = true, columnDefinition = "float(11,1) COMMENT '资源需求(人月）'")
	private Float resourceNeeded;

	@Column(name = "parent_id", nullable = false, columnDefinition = "bigint COMMENT '关联课题主键ID'")
	private Long parentId;

	@Column(name = "human_budgeting", nullable = true, columnDefinition = "float(11,1) COMMENT '课题规划预算（不包含人力）'")
	private Float humanBudgeting;

	@Column(name = "budgeting", nullable = true, columnDefinition = "float(20,1) COMMENT '总预算'")
	private Float budgeting;

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		TechProjectInfoHistoryEntity other = (TechProjectInfoHistoryEntity) obj;
		if (id == null) {
			if (other.id != null) {
				return false;
			}
		} else if (!id.equals(other.id)) {
			return false;
		}
		return true;
	}
}
